package ac.il.technion.c236369.hw4.core.protocol;

import org.apache.http.protocol.HttpRequestHandler;
import org.apache.http.protocol.HttpRequestHandlerRegistry;

/**
 * @author Artem Barger, Maxim Aizenshtein
 *
 * Class which inherits from HttpRequestHandlerRegistry,
 * reimplenent lookup method to return a default handler
 * to be able to serve files for them there is no type handler defined.
 *
 */
public class RequestRegistry extends HttpRequestHandlerRegistry {

	private HttpRequestHandler defaultHandler;

	
	public RequestRegistry( HttpRequestHandler defaultHandler) {
		this.defaultHandler = defaultHandler;
	}
	
	@Override
	public HttpRequestHandler lookup(String requestURI) {
		HttpRequestHandler $ = super.lookup(requestURI);
		if ( null == $)
			return defaultHandler;
		return $;
	}

}
